package com.share.rules.api;

import com.share.common.core.constant.ServiceNameConstants;
import com.share.common.core.domain.Result;
import com.share.rules.domain.FeeRule;
import com.share.rules.domain.FeeRuleRequestForm;
import com.share.rules.domain.FeeRuleResponseVo;
import com.share.rules.fallback.RemoteFeeRuleFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * feeRule远程调用客户端
 */
@FeignClient(
        contextId = "remoteFeeRuleService",
        value = ServiceNameConstants.RULE_SERVICE,
        fallbackFactory = RemoteFeeRuleFallbackFactory.class) //降级类fallback
public interface RemoteFeeRuleService {

    //批量获取费用规则信息
    @PostMapping(value = "/feeRule/getFeeRuleList")
    public Result<List<FeeRule>> getFeeRuleList(@RequestBody List<Long> feeRuleIds);

    //获取费用规则详细信息
    @GetMapping(value = "/feeRule/getFeeRule/{id}")
    public Result<FeeRule> getFeeRule(@PathVariable("id") Long id);

    //使用规则引擎计算订单金额
    @PostMapping("/feeRule/calculateOrderFee")
    public Result<FeeRuleResponseVo> calculateOrderFee(@RequestBody FeeRuleRequestForm feeRuleRequestForm);
}
